package td;

import java.util.Map;
import java.util.TreeMap;

import bbb.sss.Utils;

public class Main2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		test5();
	}

	public static void test5() {
		int count = 100000;
		int i = 1;

		int lastIndex = 0;
		int sum = 0;
		Map<Integer, Integer> thrStep = new TreeMap<Integer, Integer>();
		Map<Integer, Integer> lengthCount = new TreeMap<Integer, Integer>();

		int dd = 0;
		
		while (i <= count) {
			int cc = Utils.randomNumber(1000) - 1;
			TD td = new TD(cc);
			System.out.println(cc);
			int type = td.type();

			if (type == TD.THR_COMB) {
				int length = i - lastIndex;
				thrStep.put(i, length);
				sum += length;

				Main.mapAdd(lengthCount, length, 1);

				lastIndex = i;
				dd++;
			}
			i++;
		}

		System.out
				.println("-------------------------------------------------------------");
		System.out.println(thrStep.size() + " --> " + sum * 1.0
				/ thrStep.size());
		for (Integer key : thrStep.keySet()) {
			System.out.println(key + " ===> " + thrStep.get(key));
		}
		System.out
				.println("-------------------------------------------------------------");
		System.out.println(dd);
		for (Integer key : lengthCount.keySet()) {
			System.out.println(key + " ===> " + lengthCount.get(key) +" ===> "+lengthCount.get(key) * 1.0 / dd);
		}
	}
	
	public static void test6() {
		int count = 1000;
		int i = 1;

		int lastIndex = 0;
		int sum = 0;
		Map<Integer, Integer> thrStep = new TreeMap<Integer, Integer>();
		Map<Integer, Integer> lengthCount = new TreeMap<Integer, Integer>();

		while (i <= count) {
			int cc = Utils.randomNumber(1000) - 1;
			TD td = new TD(cc);
			System.out.println(cc);
			int type = td.type();

			if (type == TD.THR_COMB) {
				int length = i - lastIndex;
				thrStep.put(i, length);
				sum += length;

				Main.mapAdd(lengthCount, length, 1);

				lastIndex = i;
			}
			i++;
		}

		System.out
				.println("-------------------------------------------------------------");
		System.out.println(thrStep.size() + " --> " + sum * 1.0
				/ thrStep.size());
		for (Integer key : thrStep.keySet()) {
			System.out.println(key + " ===> " + thrStep.get(key));
		}
		System.out
				.println("-------------------------------------------------------------");
		for (Integer key : lengthCount.keySet()) {
			System.out.println(key + " ===> " + lengthCount.get(key) +" ===> "+lengthCount.get(key) * 1.0 / count);
		}
	}
}
